include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-overthewall
PKG_VERSION:=1.0
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define Package/luci-app-overthewall
SECTION:=LuCI
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI Support for overthewall list
PKGARCH:=all
endef

define Package/luci-app-overthewall/description
LuCI Support for overthewall list
endef

define Build/Compile
endef

define Package/luci-app-overthewall/postinst
#!/bin/sh
( . /etc/uci-defaults/luci-overthewall ) && rm -f /etc/uci-defaults/luci-overthewall
exit 0
endef

define Package/luci-app-overthewall/prerm
#!/bin/sh
/etc/init.d/overthewall disable >/dev/null 2>&1
exit 0
endef

define Package/luci-app-overthewall/postrm
#!/bin/sh
uci -q batch <<-EOF >/dev/null
	delete ucitrack.@overthewall[-1]
	commit ucitrack
EOF
rm -f /tmp/luci-indexcache
rm -rf /tmp/luci-modulecache
exit 0
endef

define Package/luci-app-overthewall/install
	$(CP) ./root/* $(1)
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/overthewall.init $(1)/etc/init.d/overthewall
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_CONF) ./files/overthewall.config $(1)/etc/config/overthewall
	$(INSTALL_DIR) $(1)/etc/uci-defaults
	$(INSTALL_BIN) ./files/luci-overthewall.uci $(1)/etc/uci-defaults/luci-overthewall
endef

$(eval $(call BuildPackage,luci-app-overthewall))
